package cz.proks.simplecalendarmanager.server.utils;

import com.google.gdata.data.calendar.CalendarEntry;

public class CalendarUtils {
	public static String getCalendarId(CalendarEntry calendarEntry) {
		String htmlId = calendarEntry.getId();
		int htmlIdLength = htmlId != null ? htmlId.length() : -1;
		
		int startIndex = htmlId != null ? htmlId.lastIndexOf('/') : -1;
		startIndex = startIndex != -1 ? (htmlIdLength >= startIndex + 1 ? startIndex + 1 : -1) : -1; 
		
		int endIndex = htmlIdLength;
		return startIndex >= 0 && (startIndex <= endIndex) ? htmlId.substring(startIndex, endIndex) : null;
	}
}
